package com.qeegoo.b2bautozityp.moudle.good.viewmodel;

import android.databinding.ObservableField;

import com.kelin.mvvmlight.command.ReplyCommand;
import com.qeegoo.b2bautozityp.moudle.good.model.GoodsPropertyBean;
import com.qeegoo.b2bautozityp.moudle.good.model.GoodsWareHouseBean;
import com.qeegoo.b2bautozityp.moudle.good.view.GoodsActivity;

import base.lib.util.ActivityManager;

/**
 * 王少岩 在 2017/9/19 创建了它
 */

public class GoodsPropertyItemViewModel {
    public ObservableField<String> code = new ObservableField<>("");
    public ObservableField<String> name = new ObservableField<>("");
    public ObservableField<Boolean> selected = new ObservableField<>(false);
    public String label;

    public GoodsPropertyItemViewModel(String label, String info, GoodsPropertyBean.GoodsProperty goodsProperty) {
        this.label = label;
        code.set(goodsProperty.code);
        this.name.set(goodsProperty.name);
        selected.set(this.name.get().equals(info));
    }

    public GoodsPropertyItemViewModel(String label, String info, GoodsWareHouseBean goodsWareHouseBean) {
        this.label = label;
        code.set(goodsWareHouseBean.id);
        this.name.set(goodsWareHouseBean.name);
        selected.set(this.name.get().equals(info));
    }

    public ReplyCommand selectCommand = new ReplyCommand(()-> ((GoodsActivity)ActivityManager.getActivity()).setProperty(label, code.get(), name.get()));
}
